﻿@inherits AdminCompontentBase

<div class="d-flex" style="height: calc(100vh - 280px);">
    <LoginRegisterTemplate Tab=@CustomLoginTab.Login Logo="@Logo" Title="@Title" ThirdPartyIdps="Value.Where(value => ThirdPartyIdps.Any(item => item.Id == value.Id)).Select(value => ThirdPartyIdps.First(item => item.Id == value.Id)).ToList()" />
    <div style="border: 1px solid #E2E7F4;" class="mx-12 full-height" />
    <div class="mt-5 full-height flex-column" style="width:100%">
        <div class="overflow-y">
            <MRow>
                <MCol Cols="6">
                    <span class="body2 regular3--text">
                        @T("TitleName")
                    </span>
                </MCol>
                <MCol Cols="2">
                    <span class="body2 regular3--text">
                        @T("Category")
                    </span>
                </MCol>
                <MCol>
                    <span class="body2 regular3--text">
                        @T("Action")
                    </span>
                </MCol>
            </MRow>
            <div class="mt-5">
                @foreach (var thirdPartyIdp in Value)
                {
                    <MRow Class="mb-6" @key="@(thirdPartyIdp.Id!=default?thirdPartyIdp.Id:thirdPartyIdp.Sort)">
                        <MCol Cols="6">
                            <ThirdPartyIdpSelect @bind-Value="thirdPartyIdp.Id" ThirdPartyIdps="ThirdPartyIdps" Excludes="Value.Select(v => v.Id).ToList()" FillBackground=false />
                        </MCol>
                        <MCol Cols="2" Class="d-flex">
                            <div class="my-auto">
                                @T(ThirdPartyIdps.FirstOrDefault(tp => tp.Id == thirdPartyIdp.Id)?.AuthenticationType.ToString()??"")
                            </div>                           
                        </MCol>
                        <MCol Class="d-flex">
                            <div class="my-auto">
                                <MButton Class="mr-6" Icon OnClick="async () =>await Up(thirdPartyIdp)" Disabled="thirdPartyIdp.Sort == Value.Min(v => v.Sort)">
                                    <SIcon Tooltip="@T("Up")" >mdi-menu-up</SIcon>
                                </MButton>
                                <MButton Class="mr-6" Icon OnClick="async () =>await Down(thirdPartyIdp)" Disabled="thirdPartyIdp.Sort == Value.Max(v => v.Sort)">
                                    <SIcon Tooltip="@T("Down")">mdi-menu-down</SIcon>
                                </MButton>
                                <MButton Class="mr-6" Icon OnClick="async () =>await Remove(thirdPartyIdp)">
                                    <SIcon Tooltip="@T("Delete")">mdi-delete-outline</SIcon>
                                </MButton>
                            </div>
                        </MCol>
                    </MRow>
                }
            </div>
        </div>
    </div>
</div>